home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  3.7 KB  |  122 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: init.c,v 1.1 87/02/12 10:58:25 schoch Exp $";
  3. #endif
  4.  
  5. #include "externs.h"
  6. #include <ctype.h>
  7.  
  8. initdirlists ()
  9. {
  10.     LIST linsert ();
  11.     dirlist [PAWN] = (LIST) NIL;
  12.     dirlist [KING] = linsert (linsert (linsert (linsert (linsert (linsert
  13.          (linsert (linsert ((LIST) NIL, -10), -9), 1), 11), 10), 9), -1), -11);
  14.     dirlist [KNIGHT] = linsert (linsert (linsert (linsert (linsert (linsert
  15.      (linsert (linsert ((LIST)NIL, -19),-8), 12), 21), 19), 8), -12), -21);
  16.     dirlist [BISHOP] = linsert (linsert (linsert (linsert
  17.             ((LIST) NIL, -9), 11), 9), -11);
  18.     dirlist [ROOK] = linsert (linsert (linsert (linsert
  19.             ((LIST) NIL, -10), 1), 10), -1);
  20.     dirlist [QUEEN] = linsert (linsert (linsert (linsert (linsert (linsert
  21.           (linsert (linsert ((LIST) NIL, -10),-9), 1), 11), 10), 9), -1), -11);
  22. }
  23.  
  24. initpiecelocs ()
  25. {
  26.     piecelocs [BLACK] = linsert (linsert (linsert (linsert (linsert
  27.             (linsert (linsert (linsert (linsert (linsert (linsert (linsert
  28.         (linsert (linsert (linsert (linsert ((LIST) NIL, 11), 12), 13), 14)
  29.             , 15), 16), 17), 18), 21), 22), 23), 24), 25), 26), 27), 28);
  30.         piecelocs [WHITE] = linsert (linsert (linsert (linsert (linsert
  31.             (linsert (linsert (linsert (linsert (linsert (linsert (linsert
  32.             (linsert (linsert (linsert (linsert ((LIST) NIL, 71), 72), 73), 74)
  33.             , 75), 76), 77), 78), 81), 82), 83), 84), 85), 86), 87), 88);
  34.     kingloc [WHITE] = 85;
  35.     kingloc [BLACK] = 15;
  36. }
  37.  
  38.  
  39. initboard(allpieces)
  40.     int allpieces;
  41. {
  42.     int row, col, spot, i, j;
  43.     static u_char initwhose [100] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
  44.                         3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
  45.                         3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
  46.                         3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
  47.                         3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
  48.                         3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
  49.                         3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
  50.                         3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
  51.                         3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
  52.                         3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
  53.  
  54.     static int initoccupant [100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  55.                       0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
  56.                       0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
  57.                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  58.                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  59.                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  60.                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  61.                       0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
  62.                       0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
  63.                       0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  64.  
  65.     if (ourcolor == WHITE)
  66.         theircolor = BLACK;
  67.     else if (ourcolor == BLACK)
  68.         theircolor = WHITE;
  69.     for (i = 0; i < 100; i++) {
  70.         whose [i] = initwhose [i];
  71.         occupant [i] = initoccupant [i];
  72. #ifdef XKS
  73.         if (whose[i] == theircolor)
  74.             ghost[i] = occupant[i];
  75.         else
  76.             ghost[i] = 0;
  77. #endif
  78.         virgin[i] = TRUE;
  79.     }
  80.  
  81. #ifdef XKS
  82.     for (i = 0; i < 32; i++)
  83.         captured[i] = 0;
  84. #else
  85.     for (row = 0; row <= 7; row++)
  86.         for (col = 0; col <= 7; col ++) {
  87.             if (ourcolor == WHITE) {
  88.                 i = row;
  89.                 j = col;
  90.             } else {
  91.                 i = 7 - row;
  92.                 j = 7 - col;
  93.             }
  94.             spot = 10 * (row + 1) + (col + 1);
  95.             blanksq [spot] = subwin (stdscr, sqheight, sqwidth,
  96.                          sqheight * i, sqwidth * j);
  97.             square [spot] = subwin (stdscr, 1, 1,
  98.                       (sqheight * i) + (sqheight / 2),
  99.                       (sqwidth * j) + (sqwidth / 2));
  100.             if (reversescr && (row + col) % 2 == 0) {
  101.                 wstandout (blanksq [spot]);
  102.                 wstandout (square [spot]);
  103.             }
  104.             for (i = 1; i <= sqwidth; i++)
  105.                 for (j = 1; j <= sqheight; j++)
  106.                     waddch (blanksq [spot], ' ');
  107.             waddch (square [spot], sqcolor [(row + col) % 2]);
  108.         }
  109.     for (row = 1; row <= 2; row++)
  110.         for (col = 1; col <= 8; col++) {
  111.             if (ourcolor == WHITE)
  112.                 spot = 10 * (9 - row) + col;
  113.             else
  114.                 spot = 10 * row + col;
  115.             waddch (square [spot], symbol [occupant [spot]]);
  116.             if (allpieces)
  117.                 waddch (square [99 - spot], tolower
  118.                     (symbol [occupant [99 - spot]]));
  119.         }
  120. #endif XKS
  121. }
  122.